package com.ctshk.rpc.order.tour.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ctshk.rpc.order.tour.base.CustomBaseMapper;
import com.ctshk.rpc.order.tour.dto.SeriesOrderReceiptTouristListDTO;
import com.ctshk.rpc.order.tour.entity.SeriesOrderReceiptTourist;
import com.ctshk.rpc.order.tour.req.SeriesOrderReceiptTouristListReq;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 * 系列团收据关联游客 Mapper 接口
 * </p>
 *
 * @author 谭响
 * @since 2021-02-01
 */
public interface SeriesOrderReceiptTouristMapper extends CustomBaseMapper<SeriesOrderReceiptTourist> {

    @SelectProvider(type = SeriesOrderReceiptTouristProvider.class, method = "selectListBySelective")
    List<SeriesOrderReceiptTouristListDTO> selectListBySelective(@Param("req") SeriesOrderReceiptTouristListReq req);

    /**
     * 清空订单收据关联旅客
     * @param orderId
     * @param userId
     */
    @Update("UPDATE t_series_order_receipt_tourist\n" +
            "SET is_deleted = 1,modified_id = #{user_id}\n" +
            "WHERE order_id = #{order_id} AND is_deleted = 0")
    void cleanByOrder(@Param("order_id") Long orderId, @Param("user_id") Long userId);
}
